import { useEffect, useState } from 'react'
import './App.css'
import axios from 'axios'

const baseUrl = 'http://localhost:1314/api';

function App() {
  const [str, setStr] = useState('');

  useEffect(async () => {
    await axios.get(baseUrl + '/user/12345?name=daxia')
      .then(res => {
        console.log(res)
        setStr(res.data)
      })
      .catch(res => {
        console.log(res);
      })
     
    await axios.post(baseUrl + '/user', {
        firstname: 'liu',
        lastname: 'yu'
    })
      .then(res => {
          console.log(res)
      })
      .catch(err => {
          console.log(err)
      })
    
  }, [])
  return (
    <div className="App">
      <h1>
        GET 请求: 
      </h1>
      <div dangerouslySetInnerHTML={{__html: str}}></div>
      
      
    </div>
  )
}

export default App
